﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Model.AssetRegister;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;
using IsmsExplorer.Infrastructure.Helper;

namespace IsmsExplorer.Infrastructure.Repositories {
    internal class AssetCategoryFactory : IEntityFactory<AssetCategory> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string Name = "Name";
        } // end internal static class FieldNames

        public AssetCategory BuildEntity(System.Data.IDataReader reader) {
            return new AssetCategory(DataHelper.GetInteger(reader[FieldNames.ID]), reader[FieldNames.Name].ToString());
        }
    }

    internal class LocationFactory : IEntityFactory<Location> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string Name = "Name";
        } // end internal static class FieldNames

        public Location BuildEntity(System.Data.IDataReader reader) {
            return new Location(DataHelper.GetInteger(reader[FieldNames.ID]), reader[FieldNames.Name].ToString());
        }
    }

    internal class RoleFactory : IEntityFactory<Role> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string Name = "Name";
        } // end internal static class FieldNames

        public Role BuildEntity(System.Data.IDataReader reader) {
            return new Role(DataHelper.GetInteger(reader[FieldNames.ID]), reader[FieldNames.Name].ToString());
        }
    }

    internal class AssetFactory : IEntityFactory<Asset> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string Name = "Name";
            public const string ValueCIA = "ValueCIA";
            public const string CategoryID = "CategoryID";
            public const string OwnerRoleID = "OwnerRoleID";
            public const string LocationID = "LocationID";
            public const string ProjectID = "ProjectID";

        } // end internal static class FieldNames

        public Asset BuildEntity(System.Data.IDataReader reader) {
            return new Asset(DataHelper.GetInteger(reader[FieldNames.ID]), reader[FieldNames.Name].ToString(), reader.GetInt32(reader.GetOrdinal(FieldNames.ValueCIA)));
        }
    }

} // end namespace IsmsExplorer.Infrastructure.Repositories
